#!/usr/bin/env php
<?php
/**
 * @Author: Wang chunsheng  email:2192138785@qq.com
 * @Date:   2021-01-19 20:26:00
 * @Last Modified by:   Wang chunsheng  email:2192138785@qq.com
 * @Last Modified time: 2022-11-30 18:23:35
 */

use ddswoole\components\http\HttpServer;
use function Swoole\Coroutine\run;

\Co::set(['hook_flags' => SWOOLE_HOOK_ALL]);
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', getenv('PHP_ENV') === 'development' ? 'dev' : 'prod');

require __DIR__.'/vendor/autoload.php';
require __DIR__.'/vendor/yiisoft/yii2/Yii.php';

$config = yii\helpers\ArrayHelper::merge(
    [
        'app' => [
            'params' => yii\helpers\ArrayHelper::merge(
                require(__DIR__.'/common/config/params.php'),
                require(__DIR__.'/common/config/params-local.php'),
            ),
        ],
    ],
    require __DIR__.'/swoole/config/server.php'
);

\Swoole\Runtime::enableCoroutine(SWOOLE_HOOK_ALL);
$result = run(function () use ($config) {
    $server = new HttpServer($config);
    $server->run();
});
\Swoole\Runtime::enableCoroutine(false);

return $result;
